import BaiduMap from "vue-baidu-map/components/map/Map.vue";
import BmGeolocation from "vue-baidu-map/components/controls/Geolocation.vue";
import BmControl from "vue-baidu-map/components/controls/Control.vue";
import BmNavigation from "vue-baidu-map/components/controls/Navigation.vue";
import BmCityList from "vue-baidu-map/components/controls/CityList.vue";
import BmScale from "vue-baidu-map/components/controls/Scale.vue";
import BmCircle from "vue-baidu-map/components/overlays/Circle.vue";
export default {
  name: "location",
  components: {
    BaiduMap,
    BmGeolocation,
    BmNavigation,
    BmCityList,
    BmScale,
    BmCircle,
    BmControl
  },
  data: function() {
    return {
      location: {
        center: { lat: 0, lng: 0 },
        zoom: 3,
        ak: "xtV4r5RTq80MNEDwvHmHsEfQWQZ58iWF",
        radius: 500,
        showCircle: false,
        address: []
      }
    };
  },
  methods: {
    handlerMap({ BMap, map }) {
      console.log(BMap, map);
      this.location.zoom = 15;
    },
    updateCirclePath(e) {
      this.location.center = e.target.getCenter();
      this.location.radius = e.target.getRadius();
    },
    autoLocationSuccess(point, AddressComponent, marker) {
      console.log(point);
      this.location.center = point.point;
    },
    autoLocationError(statusCode) {
      alert(statusCode);
    }
  }
};
